import sim, sim_items, main
from util import *
import random

class FrenziedPrefix(sim_items.Prefix):
    def __init__(self):
        super(FrenziedPrefix, self).__init__(
            "frenzied", # name
            "This %(wearable)s has been treated with lycanthrope musk. "
            "Over time, the pheromones contained in the pungent odor wafting "
            "from this %(wearable)s will drive one into a state of frenzy."
        )

    def initialize(self, wearable):
        if not isinstance(wearable, sim_items.Armor):
            raise ValueError('Tried to apply %r to non-armor item: %r' % (self,
                wearable))
        if 'hands' not in wearable.wearSlots:
            return 
        super(FrenziedPrefix, self).initialize(wearable)
        
        self.hitPenalty = random.randint(1,3)
        self.damageBonus = random.randint(3,6)
        self.staminaBonus = random.randint(10,20)
        self.wearable.bonuses.update({
            'hitMod': self.wearable.bonuses['hitMod'] - self.hitPenalty,
            'damageSkewMod': self.wearable.bonuses['damageSkewMod'] + self.damageBonus,
            'maxStaminaMod': self.wearable.bonuses['maxStaminaMod'] + self.staminaBonus,
            
        })

    def remove(self, wearable):
        super(FrenziedPrefix, self).remove(wearable)
        self.wearable.bonuses.update({
            'hitMod': self.wearable.bonuses['hitMod'] + self.hitPenalty,
            'damageSkewMod': self.wearable.bonuses['damageSkewMod'] - self.damageBonus,
            'maxStaminaMod': self.wearable.bonuses['maxStaminaMod'] - self.staminaBonus,
        })

#========================================
thingClass = FrenziedPrefix
